<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>会话sessionStorage</title>
</head>

<body>
    <h2>点我保存一个数据</h2>
    <input type="button" value="点我保存一个数据" onclick="saveData()"></input>
    <input type="button" value="点我查询一个数据" onclick="selectData()"></input>
    <input type="button" value="点我删除一个数据" onclick="deleteData()"></input>
    <input type="button" value="点我清空一个数据" onclick="deleteAll()"></input>


</body>
<script type="text/javascript">
    let p = { name: "张三", address: "湖南" }

    function saveData() {
        // window.sessionStorage
        //浏览器本地存储 浏览器关掉数据清空，刷新数据存在
        sessionStorage.setItem('msg', 'hello')
        sessionStorage.setItem('person', JSON.stringify(p))
    }
    function selectData() {
        console.log(sessionStorage.getItem('person'))

    }
    function deleteData() {
         sessionStorage.removeItem('person')
    }
    function deleteAll(){
        sessionStorage.clear();
    }

</script>

</html>